return a*b;
}
function calculate(uint a, uint b, uint c) public pure
returns(uint) {
return a*b/c;
}
}
2.5.21 Abstract Contracts and Interfaces
In larger projects, we need to handle multiple Solidity files and a
huge number of contracts interacting with each other. Also, in order
to make the code modular, we might need to exploit the object-
oriented features of Solidity. To fascilitate this, we usually use two of
the following ways:
Abstract contracts
Interfaces
2.5.21.1 Abstract Contract
We can transform any contract to an abstract contract just by adding
a keyword abstract before the contract. The abstract contract
optionally can have one or more functions that are only defined and
yet not implemented. Such functions have to be marked as “virtual”.
Refer to the following code:
// SPDX-License-Identifier: SOME IDENTIFIER
pragma solidity ^0.8.10;
abstract contract AbstractContract {
function someFunction() public pure virtual returns(string
memory);
}
Please note that an abstract contract might have all the functions
implemented and yet just adding the abstract keyword makes the
contract abstract. Refer to the following code: